package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.domain.DanmoArtLevel;
import com.muyu.danmo.service.IDanmoArtLevelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 办学层次Controller
 *
 * @author yangle
 * @date 2024-10-31
 */
@RestController
@RequestMapping("/artLevel")
public class DanmoArtLevelController extends BaseController
{
    @Autowired
    private IDanmoArtLevelService danmoArtLevelService;

    /**
     * 查询办学层次列表
     */
//    @RequiresPermissions("system:artLevel:list")
    @PostMapping("/list")
    public Result<List<DanmoArtLevel>> list(@RequestBody DanmoArtLevel danmoArtLevel)
    {

        List<DanmoArtLevel> list = danmoArtLevelService.selectDanmoArtLevelList(danmoArtLevel);
        return Result.success(list);
    }

    /**
     * 导出办学层次列表
     */
//    @RequiresPermissions("system:artLevel:export")
    @Log(title = "办学层次", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoArtLevel danmoArtLevel)
    {
        List<DanmoArtLevel> list = danmoArtLevelService.selectDanmoArtLevelList(danmoArtLevel);
        ExcelUtil<DanmoArtLevel> util = new ExcelUtil<DanmoArtLevel>(DanmoArtLevel.class);
        util.exportExcel(response, list, "办学层次数据");
    }

    /**
     * 获取办学层次详细信息
     */
//    @RequiresPermissions("system:artLevel:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoArtLevelService.selectDanmoArtLevelById(id));
    }

    /**
     * 新增办学层次
     */
//    @RequiresPermissions("system:artLevel:add")
    @Log(title = "办学层次", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoArtLevel danmoArtLevel)
    {
        return toAjax(danmoArtLevelService.insertDanmoArtLevel(danmoArtLevel));
    }

    /**
     * 修改办学层次
     */
//    @RequiresPermissions("system:artLevel:edit")
    @Log(title = "办学层次", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoArtLevel danmoArtLevel)
    {
        return toAjax(danmoArtLevelService.updateDanmoArtLevel(danmoArtLevel));
    }

    /**
     * 删除办学层次
     */
//    @RequiresPermissions("system:artLevel:remove")
    @Log(title = "办学层次", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoArtLevelService.deleteDanmoArtLevelByIds(ids));
    }
}
